package com.hx.er.action.admin.settings;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.hx.er.action.base.ErAdminPageAction;
import com.hx.er.bean.detail.DistrictDetailBean;
import com.hx.er.common.util.StringUtil;
import com.hx.er.service.admin.IAdminSettingsService;

public class AdminDistrictListAction extends ErAdminPageAction {

	// 序列化ID
	private static final long serialVersionUID = 2487585146579189747L;

	private List<DistrictDetailBean> districtDetailList;
	private String localDistrictName;
	private long cityId;

	@Autowired
	private IAdminSettingsService adminSettingsService;

	public String init() {
		// 检索条件
		Map<String, Object> conditions = super.getConditionMap();
		conditions.put("cityId", this.cityId);
		conditions.put("localDistrictName", StringUtil.EmptyToNull(StringUtil.trim(this.localDistrictName)));
		
		// 查询列表
		this.districtDetailList = this.adminSettingsService.getDistrictDetailList(conditions);
		int districtCount = this.adminSettingsService.getDistrictDetailCount(conditions);
		super.pageCount = (int) Math.ceil(districtCount / (double) super.dataListLimit);
		
		return SUCCESS;
	}

	public long getCityId() {
		return cityId;
	}

	public void setCityId(long cityId) {
		this.cityId = cityId;
	}

	public String getLocalDistrictName() {
		return localDistrictName;
	}

	public void setLocalDistrictName(String localDistrictName) {
		this.localDistrictName = localDistrictName;
	}

	public List<DistrictDetailBean> getDistrictDetailList() {
		return districtDetailList;
	}

	public void setDistrictDetailList(List<DistrictDetailBean> districtDetailList) {
		this.districtDetailList = districtDetailList;
	}
}
